package com.xbongbong.admin.model.impl;

import com.xbongbong.admin.domain.dao.BusinessRuleInfoRetainDao;
import com.xbongbong.admin.domain.entity.BusinessRuleInfoRetainEntity;
import com.xbongbong.admin.model.BusinessRuleInfoRetainModel;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.paas.toolbox.util.DateTimeUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * 业务规则-镜像备份
 * @author xingxing.xiao
 * @date 2020/06/11 16:58
 */
@Service("businessRuleInfoRetainModel")
public class BusinessRuleInfoRetainModelImpl implements BusinessRuleInfoRetainModel {

    @Resource
    private BusinessRuleInfoRetainDao businessRuleInfoRetainDao;

    @Override
    public Integer insert(BusinessRuleInfoRetainEntity entity) {
        long now = DateTimeUtil.getInt();
        entity.setAddTime(now);
        entity.setUpdateTime(now);
        return businessRuleInfoRetainDao.insert(entity);
    }

    @Override
    public Integer update(BusinessRuleInfoRetainEntity entity) throws XbbException {
        long now = DateTimeUtil.getInt();
        entity.setUpdateTime(now);
        return businessRuleInfoRetainDao.update(entity);
    }

    @Override
    public List<BusinessRuleInfoRetainEntity> findEntitys(Map<String, Object> param) {
        return businessRuleInfoRetainDao.findEntitys(param);
    }

    @Override
    public Integer getEntitysCount(Map<String, Object> param) {
        return businessRuleInfoRetainDao.getEntitysCount(param);
    }

    @Override
    public List findEntitysWithoutSub(Map<String, Object> param) {
        return null;
    }

    @Override
    public Integer delete(Long key, String corpid) {
        return businessRuleInfoRetainDao.deleteByKey(key, corpid);
    }

    @Override
    public Integer deleteBatch(List<Long> list, String corpid) {
        return businessRuleInfoRetainDao.deleteBatch(list, corpid);
    }

    @Override
    public List<BusinessRuleInfoRetainEntity> insertBatch(List<BusinessRuleInfoRetainEntity> list) {
        businessRuleInfoRetainDao.insertBatch(list);
        return list;
    }
}
